# 1merge
MERGE = task_1merge.cc
MERGE_LIB = libtask_1merge.so
#2add case and unroll
THREAD = task_2thread.cc
THREAD_LIB = libtask_2thread.so

JUMP = task_2thread_jump.cc
JUMP_LIB = libtask_2thread_jump.so
#3aff 
AFF = task_3thread_aff.cc
AFF_LIB = libtask_3thread_aff.so
# cbt
CBT = task_3thread_cbt.cc
CBT_LIB = libtask_3thread_cbt.so
# 4 omp
OMP = task_4mulg.cc
OMP_LIB = libtask_4omp.so
# 5 threadpool
POOL = task_5thread_pool.cc
POOL_LIB = libtask_5thread_pool.so

# 6 lock
LOCK = task_6thread_lock.cc
LOCK_LIB = libtask_6thread_lock.so

# 6 lock
JCBT = task_10thread_jcbt.cc
JCBT_LIB = libtask_10thread_jcbt.so

LOOP = 4
NUM = 32768
TOL = 1e-13
CC = gcc

# 赛方的版本
gold: libcompetition.out 
	./testApp -load ./libcompetition.out -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)
#1 merge 合并taskB中多个循环+临时变量
merge:$(MERGE)
	$(CC) $(MERGE) -O2 -shared -fPIC  -o $(MERGE_LIB)
merge_run:$(MERGE_LIB)
	./testApp -load ./$(MERGE_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)
#2 多线程
thread:$(THREAD)
	$(CC) $(THREAD) -O2 -lpthread -shared -fPIC  -o $(THREAD_LIB)
thread_run:$(THREAD_LIB)
	./testApp -load ./$(THREAD_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

jump:$(JUMP)
	$(CC) $(JUMP) -O2 -lpthread -shared -fPIC  -o $(JUMP_LIB)
jump_run:$(JUMP_LIB)
	./testApp -load ./$(JUMP_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

#3 亲和性
aff:$(AFF)
	$(CC) $(AFF) -O2 -lpthread -shared -fPIC  -o $(AFF_LIB)
aff_run:$(AFF_LIB)
	./testApp -load ./$(AFF_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)
# cbt
cbt:$(CBT)
	$(CC) $(CBT) -O2 -lpthread -shared -fPIC  -o $(CBT_LIB)
cbt_run:$(CBT_LIB)
	./testApp -load ./$(CBT_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

#4 omp
omp:$(OMP)
	$(CC) $(OMP) -O2 -lpthread -fopenmp -shared -fPIC  -o $(OMP_LIB)
omp_run:$(OMP_LIB)
	./testApp -load ./$(OMP_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)
# 5 thread_pool
pool:$(POOL)
#	$(CC) $(POOL) thpool.c -D THPOOL_DEBUG -O2 -pthread -shared -fPIC  -o $(POOL_LIB)
	$(CC) $(POOL) thpool.c  -O2 -pthread -shared -fPIC  -o $(POOL_LIB)
pool_run:$(POOL_LIB)
	./testApp -load ./$(POOL_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

# 6lock
lock:$(LOCK)
	$(CC) $(LOCK)  -O2 -pthread -shared -fPIC  -o $(LOCK_LIB)
lock_run:$(POOL_LIB)
	./testApp -load ./$(LOCK_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

#10 jcbt
jcbt:$(JCBT)
	$(CC) $(JCBT)  -O2 -pthread -shared -fPIC  -o $(JCBT_LIB)
jcbt_run:$(JCBT_LIB)
	./testApp -load ./$(JCBT_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)	


clean:
	rm -f *.so *.o

